package com.example.service.impl;

import com.example.dao.UserDao;
import com.example.entity.User;
import com.example.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    @Override
    public boolean saveUser(User user) {
        Boolean isExist = userDao.getUserById(user.getUserId());
        if (isExist) {
            return false;
        } else {
            return userDao.insertUser(user);
        }
    }

    @Override
    public User getUserByIdByPass(User user) {
        return userDao.getUserByIdByPass(user);
    }

    @Override
    public List<User> listAllUsers() {
        return userDao.listAllUsers();
    }
}